package com.canglion.ragflow;

import com.canglion.ragflow.config.RAGFlowConfig;
import com.canglion.ragflow.pojo.kb.KbApiResponse;

/**
 * rundreams.blog.csdn.net
 *
 * @Time:2025/9/4
 * @Author: Zihao Zhang
 * @description:
 */

public class App {

    public static void main(String[] args) {
        RAGFlowConfig config = RAGFlowConfig.builder()
                .baseUrl("http://11.0.1.141:8077")
                .username("master@yunxinai.com")
                .password("IiryvK5cu05vmzIkNECYa7m+46e26p0o1A5cKfbczTca/OURRzDvQ65hMK/6mjMZgJ2HG9J4LKkCVDvFVYgkENgtaBBtMpQhnvBt/gklutQvDKP1Z9SL4xXJHJwG9C/qYnagd9OAe1VXzh5Q2J9qAzPZur9LecRKkjrQWnpPU20cUpoSMIyX8Tyg6+CyiDW3o9QwlPDa8wSFo+r9YuUtOT9CE9IAzEApcnfJl5sZh4JppFMRPaccpjxojsb4DRx4479abGt5UJoxjNYmYEK7NMdvOnzZ0UOiL8shQLc52a/k3PG4MG6tGz+tr/TN0IGU/DeIEI2PZXUiaAzKmetvdA==")
                .build();

        try (RAGFlowClient client = new RAGFlowClient(config)) {

            String token = client.getAuthManager().getAccessToken();
            KbApiResponse kbApiResponse = client.kb().create("刚刚创建的知识库");
            System.out.println("kbApiResponse = " + kbApiResponse);
            System.out.println("kbApiResponse.isSuccess() = " + kbApiResponse.isSuccess());
            if (!kbApiResponse.isSuccess()) {
                throw new RuntimeException("创建知识库失败");
            }
            String kbId = kbApiResponse.getData().getKb_id();
            System.out.println("kbId = " + kbId);

            // 知识库操作
//            JSONObject kbs = client.kb().list();
//            System.out.println("Knowledge Bases: " + kbs);


        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
